import pickle
import keras
import numpy as np
from keras.models import Sequential,load_model
from sklearn.metrics import classification_report
batch_size=128
epochs=20
num_classes=2
data_augmentation=False
x_train=pickle.load(open('training_data/x_train.pkl','rb'))
y_train=pickle.load(open('training_data/y_train_label.pkl','rb'))
segment_val=int(len(x_train)*0.6)
segment_test=int(len(x_train)*0.8)
try:
   x_test=np.asarray(x_train[segment_test:],dtype='float32')/255
   y_test=np.asarray(y_train[segment_test:],dtype='float32')
except:
   pass
x_train=np.asarray(x_train[:segment_val],dtype='float32')/255
y_train=np.asarray(y_train[:segment_val],dtype='float32')
binary_model=load_model('../log/checkpoint-19-1.61156.hdf5')
y_pred=binary_model.predict(x_test)
y_pred=np.asarray(y_pred)
y_pred=y_pred.reshape((y_pred.shape[1],y_pred.shape[0]))
print(y_test)
print(y_pred)
for i in range(y_pred.shape[0]):
    for j in range(y_pred.shape[1]):
        if y_pred[i][j]>0.5:
           y_pred[i][j]=1
        else:
           y_pred[i][j]=0
for i in range(y_test.shape[1]):
    count=0
    for j in range(len(y_test.T[i])):
        if y_test[j][i]==0:
           count=count+1
    print(count/y_test.shape[0]) 
for i in range(y_test.shape[1]):
     print(classification_report(y_test.T[i],y_pred.T[i]))

